using TMPro;
using UnityEngine.Events;
using UnityEngine.UI;
namespace LFramework
{
    public static class UIExtra
    {
        public static Button Subscribe(this Button btn, UnityAction action)
        {
            btn.onClick.AddListener(action);
            return btn;
        }

        public static Toggle Subscribe(this Toggle tog, UnityAction<bool> action)
        {
            tog.onValueChanged.AddListener(action);
            return tog;
        }

        public static Slider Subscribe(this Slider slider, UnityAction<float> action)
        {
            slider.onValueChanged.AddListener(action);
            return slider;
        }

        public static Dropdown Subscribe(this Dropdown dropdown, UnityAction<int> action)
        {
            dropdown.onValueChanged.AddListener(action);
            return dropdown;
        }

        public static InputField Subscribe(this InputField dropdown, UnityAction<string> action)
        {
            dropdown.onValueChanged.AddListener(action);
            return dropdown;
        }

        public static Button UnSubscribe(this Button btn, UnityAction action)
        {
            btn.onClick.RemoveListener(action);
            return btn;
        }

        public static Toggle UnSubscribe(this Toggle tog, UnityAction<bool> action)
        {
            tog.onValueChanged.RemoveListener(action);
            return tog;
        }

        public static Slider UnSubscribe(this Slider slider, UnityAction<float> action)
        {
            slider.onValueChanged.RemoveListener(action);
            return slider;
        }

        public static Dropdown UnSubscribe(this Dropdown dropdown, UnityAction<int> action)
        {
            dropdown.onValueChanged.RemoveListener(action);
            return dropdown;
        }

        public static InputField UnSubscribe(this InputField dropdown, UnityAction<string> action)
        {
            dropdown.onValueChanged.RemoveListener(action);
            return dropdown;
        }

        public static TextMeshProUGUI SetActive(this TextMeshProUGUI text, bool active)
        {
            text.gameObject.SetActive(active);
            return text;
        }
    }

}
